/**
 *  promise 形式  showToast
 * @param {object} param0 参数
 */

let ajaxTime = 0

// export const BasicUrl = "http://120.24.182.152:5000/";
// export const BasicUrl = "http://127.0.0.1:8000";
export const BasicUrl = "http://134.175.230.195:8000"



export default {
	request:(paset)=>{
		ajaxTime++
		  uni.showLoading({
			  title: '加载中',
			  mask: true
			})
		
		const baseUrl = BasicUrl;
		const header = {
			...paset.header,
			'content-type': 'application/json',
			}
		return new Promise((resolve,reject)=>{
			uni.request({
				...paset,
				header,
				url:baseUrl+paset.url,
				success:(res)=>{
					resolve(res.data)
				},
				fail:(err)=>{
					reject(err)
				},
				 complete: () => {
					ajaxTime--
					if(ajaxTime === 0){
					  uni.hideLoading()
					}
				  }
			})
		})
	},
	request2:(paset)=>{
		const baseUrl = BasicUrl;
		const header = {
			...paset.header,
			'content-type': 'application/json',
			}
		return new Promise((resolve,reject)=>{
			uni.request({
				...paset,
				header,
				url:baseUrl+paset.url,
				success:(res)=>{
					resolve(res.data)
				},
				fail:(err)=>{
					reject(err)
				},
				 complete: () => {
				
				  }
			})
		})
	}
}